require 'will_paginate'
class BigareasController < ApplicationController
  
   
  # GET /grandeareas
  # GET /grandeareas.xml
  def index
    #@bigareas  = Bigarea.paginate :page => params[:page], :order => 'nome DESC', :per_page => 8
    @nome = params[:nome]
    @bigareas =  Bigarea.search @nome, params[:page]

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @bigareas }
    end
  end

  # GET /grandeareas/1
  # GET /grandeareas/1.xml
  def show
    @bigarea = Bigarea.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @bigarea }
    end
  end

  # GET /grandeareas/new
  # GET /grandeareas/new.xml
  def new
    @bigarea = Bigarea.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @bigarea }
    end
  end

  # GET /grandeareas/1/edit
  def edit
    @bigarea = Bigarea.find(params[:id])
  end

  # POST /grandeareas
  # POST /grandeareas.xml
  def create
    @bigarea = Bigarea.new(params[:bigarea])

    @bigarea = modifica @bigarea,params[:bigarea]

    respond_to do |format|
      if @bigarea.save
        flash[:notice] = 'Grandearea was successfully created.'
        format.html { redirect_to(bigareas_url) }
        format.xml  { render :xml => @bigarea, :status => :created, :location => @bigarea }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @bigarea.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /grandeareas/1
  # PUT /grandeareas/1.xml
  def update
    @bigarea = Bigarea.find(params[:id])

    respond_to do |format|
      if @bigarea.update_attributes(params[:bigarea])
        flash[:notice] = 'Grandearea was successfully updated.'
        format.html { redirect_to(bigareas_url) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @bigarea.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /grandeareas/1
  # DELETE /grandeareas/1.xml
  def destroy
    @bigarea = Bigarea.find(params[:id])
    @bigarea.destroy

    respond_to do |format|
      format.html { redirect_to(bigareas_url) }
      format.xml  { head :ok }
    end
  end
end
